import _ from "lodash";
import SectionArticle from "./components/detail/sections/Article";
import SectionBusinessData from "./components/detail/sections/BusinessData";
import SectionDocs from "./components/detail/sections/Docs";
import SectionGroupedTable from "./components/detail/sections/GroupedTable";
import SectionImages from "./components/detail/sections/Images";
import SectionTable from "./components/detail/sections/Table";
import { toJSON } from "./utils/commons";

export const API_BASE =
  process.env.NODE_ENV === "development"
    ? "/api/"
    : "//crm.net-artisan.com/api/";

export const CompanyModules = [
  {
    key: "background",
    name: "公司背景",
    items: [
      {
        id: "introduction",
        label: " 企业介绍",
        component: SectionArticle,
        select: detail => detail.introduction
      },
      {
        id: "pictures",
        label: " 相关图片",
        component: SectionImages,
        select: detail => _.split(detail.pictures, ",").map(_.trim)
      },
      {
        id: "documents",
        label: " 相关文档",
        component: SectionDocs,
        select: detail => toJSON(detail.documents, [])
      },
      {
        id: "equityThrough",
        label: " 股权穿透",
        component: SectionTable,
        fetch: "cedar-system/equitypenetration/all",
        columns: [
          { title: "股东名称", dataKey: "name" },
          { title: "股份占比", dataKey: "inParentActualRadio" }
        ],
        mock: [
          {
            name: "百度（香港）有限公司",
            inParentActualRadio: "100%"
          }
        ]
      },
      {
        id: "outboundInvestment",
        label: " 对外投资",
        component: SectionTable,
        fetch: "cedar-system/outboundinvestment/all",
        columns: [
          { title: "被投企业名称", dataKey: "name" },
          { title: "投资金额", dataKey: "shouldCapi" },
          { title: "投资比例", dataKey: "fundedRatio" }
        ],
        mock: [
          {
            name: "百度云计算技术（保定徐水）有限公司",
            fundedRatio: "82.50%",
            shouldCapi: "165000万元人民币"
          }
        ]
      }
      // { id: "rentFreePeriod", label: " 是否有免租期" },
      // { id: "rentFreePeriodDatail", label: " 免租详情" }
    ]
  },
  {
    key: "registered",
    name: "工商信息",
    items: [
      { id: "operName", label: " 法定代表人" },
      { id: "startDate", label: " 成立时间" },
      { id: "businessTerm", label: " 营业期限" },
      { id: "registCapi", label: " 注册资本（万元）" },
      { id: "recCap", label: " 实缴资本（万元）" },
      { id: "econKind", label: " 公司类型" },
      { id: "industryType", label: " 行业领域" },
      { id: "scope", label: " 经营范围" },
      { id: "address", label: " 公司注册地址" },
      { id: "creditCode", label: " 统一社会信用代码" },
      { id: "originalName", label: " 曾用名" }
    ]
  },
  {
    key: "business",
    name: "经营状况",
    items: [
      {
        id: "enterpriseBidding",
        label: " 招投标",
        component: SectionTable,
        fetch: "cedar-system/enterprisebidding/all",
        columns: [
          { title: "发布时间", dataKey: "pubdate" },
          { title: "标题", dataKey: "title" },
          { title: "采购人", dataKey: "purchaser" },
          { title: "成交金额", dataKey: "amount" }
        ],
        mock: [
          {
            title:
              "中国移动上海公司2017浦东新区百度研发大楼房屋租赁项目_单一来源采购信息公告",
            pubdate: "2017-12-08",
            purchaser: "测试",
            amount: "10000.00"
          }
        ]
      },
      {
        id: "enterpriseStaffStatistics",
        label: " 人员信息",
        component: SectionTable,
        fetch: "cedar-system/enterprisestaffstatistics/all",
        columns: [
          { title: "年份", dataKey: "year" },
          { title: "从业人员总数", dataKey: "employeesNum" },
          { title: "大专及本科人数", dataKey: "collegeUndergraduateNum" },
          { title: "硕士及博士人员数", dataKey: "mastersDoctorsNum" }
        ],
        mock: [
          {
            year: "2021",
            employeesNum: 10,
            collegeUndergraduateNum: 20,
            mastersDoctorsNum: 30,
            graduatesNum: 40
          }
        ]
      },
      {
        id: "enterpriseMainBusiness",
        label: " 主营业务和产品",
        component: SectionTable,
        fetch: "cedar-system/enterprisemainbusiness/all",
        columns: [
          { title: "主营业务和产品", dataKey: "name" },
          { title: "收入占比", dataKey: "ratio" }
        ],
        mock: [
          {
            name: "腾讯觅影",
            ratio: "2"
          }
        ]
      },
      {
        id: "enterpriseBusinessData",
        label: " 经营数据表",
        component: SectionBusinessData,
        fetch: "cedar-system/enterprisebusinessdata/all",
        mock: [
          {
            year: "2020", //数据年份
            businessIncome: "2.00", //营业收入
            softwareBusinessIncome: "3.00", //软件业务收入
            totalCost: "5.00", //总成本
            businessCost: "7.00", //其中营业成本
            developmentCost: "9.00", //研发费用
            humanResourceCost: "11.00", //人力资源成本
            operatingProfit: "13.00", //营业利润
            netProfit: "15.00", //净利润
            totalProfit: "17.00", //利润总额
            taxPayable: "19.00", //应交税费
            businessIncomeRatioIncrease: "a", //营业收入比增
            softwareBusinessIncomeRatioIncrease: "b", //软件业务收入比增
            totalCostRatioIncrease: "c", //总成本比增
            businessCostRatioIncrease: "d", //其中营业成本比增
            developmentCostRatioIncrease: "e", //研发费用比增
            humanResourceCostRatioIncrease: "f", //人力资源成本比增
            operatingProfitRatioIncrease: "g", //营业利润比增
            netProfitRatioIncrease: "h", //净利润比增
            totalProfitRatioIncrease: "i", //利润总额比增
            taxPayableRatioIncrease: "j" //应交税费比增
          },
          {
            year: "2021", //数据年份
            businessIncome: "2.00", //营业收入
            softwareBusinessIncome: "3.00", //软件业务收入
            totalCost: "5.00", //总成本
            businessCost: "7.00", //其中营业成本
            developmentCost: "9.00", //研发费用
            humanResourceCost: "11.00", //人力资源成本
            operatingProfit: "13.00", //营业利润
            netProfit: "15.00", //净利润
            totalProfit: "17.00", //利润总额
            taxPayable: "19.00", //应交税费
            businessIncomeRatioIncrease: "", //营业收入比增
            softwareBusinessIncomeRatioIncrease: "", //软件业务收入比增
            totalCostRatioIncrease: "", //总成本比增
            businessCostRatioIncrease: "", //其中营业成本比增
            developmentCostRatioIncrease: "", //研发费用比增
            humanResourceCostRatioIncrease: "", //人力资源成本比增
            operatingProfitRatioIncrease: "", //营业利润比增
            netProfitRatioIncrease: "", //净利润比增
            totalProfitRatioIncrease: "", //利润总额比增
            taxPayableRatioIncrease: "" //应交税费比增
          }
        ]
      }
    ]
  },
  {
    key: "finance",
    name: "融资贷款",
    items: [
      {
        id: "enterpriseFinancing",
        label: " 融资信息",
        component: SectionTable,
        fetch: "cedar-system/enterprisefinancing/all",
        columns: [
          { title: "投资方", dataKey: "investment" },
          { title: "融资轮次", dataKey: "round" },
          { title: "融资金额（万元）", dataKey: "amount" },
          { title: "发生时间", dataKey: "date" }
        ],
        mock: [
          {
            date: "2018-08-09",
            round: "B轮",
            amount: "数千万人民币",
            investment: "北文投,鹏元征信"
          }
        ]
      },
      {
        id: "enterpriseLoanInformation",
        label: " 贷款信息",
        component: SectionTable,
        fetch: "cedar-system/enterpriseloaninformation/all",
        columns: [
          { title: "授信银行", dataKey: "bankName" },
          { title: "授信额度（万元）", dataKey: "approvalDate" },
          { title: "批复时间", dataKey: "amount" }
        ],
        mock: [
          {
            approvalDate: "2021-04-19",
            bankName: "测试银行",
            amount: "1000.00"
          }
        ]
      }
    ]
  },
  {
    key: "knowledge",
    name: "知识产权",
    items: [
      {
        id: "enterpriseTrademark",
        label: " 商标",
        component: SectionTable,
        fetch: "cedar-system/enterpriseloaninformation/all",
        columns: [
          { title: "商标列表", dataKey: "name" },
          { title: "申请日", dataKey: "appDate" },
          { title: "申请注册号", dataKey: "regNo" },
          { title: "商标状态", dataKey: "flowStatusDesc" }
        ],
        mock: [
          {
            regNo: "52776262",
            name: "天启查",
            flowStatusDesc: "商标注册申请-受理通知书发文-结束",
            appDate: "2021-01-06"
          }
        ]
      },
      {
        id: "enterprisePaten",
        label: " 专利",
        component: SectionGroupedTable,
        fetch: "cedar-system/enterprisepaten/all",
        columns: [
          { title: "专利内容", dataKey: "title" },
          { title: "申请日", dataKey: "applicationDate" },
          { title: "法律状态", dataKey: "legalStatusDesc" },
          { title: "公开日", dataKey: "publicationDate" }
        ],
        mock: {
          发明公布: [
            {
              applicationDate: "2019-09-03",
              publicationDate: "2021-03-05",
              legalStatusDesc: "公开",
              title: "信息推送方法、装置、设备及计算机可读存储介质"
            }
          ],
          发明授权: [
            {
              applicationDate: "2014-04-01",
              publicationDate: "2018-07-10",
              legalStatusDesc: "授权",
              title: "搜索结果的展现方法和装置"
            }
          ]
        }
      },
      {
        id: "enterpriseSoftwareCopyright",
        label: " 软件著作权",
        component: SectionTable,
        fetch: "cedar-system/enterprisesoftwarecopyright/all",
        columns: [
          { title: "软著列表", dataKey: "name" },
          { title: "登记批准日", dataKey: "publishDate" },
          { title: "软件简称", dataKey: "shortName" },
          { title: "发布日期", dataKey: "registerAperDate" }
        ],
        mock: [
          {
            publishDate: "2019-03-15",
            registerAperDate: "2019-12-06",
            name: "百度金融大脑智能决策系统",
            shortName: "决策系统"
          }
        ]
      },
      { id: "intellectualPropertyAmount", label: " 知识产权总数" }
    ]
  },
  {
    key: "space",
    name: "空间信息",
    items: [{ id: "enterpriseIncubator", label: " 空间信息" }]
  },
  {
    key: "honor",
    name: "荣誉资质",
    items: [
      {
        id: "enterpriseHonor",
        label: " 荣誉资质",
        fetch: "cedar-system/enterprisehonor/all",
        component: SectionTable,
        columns: [
          { title: "资质荣誉", dataKey: "title" },
          { title: "认证等级", dataKey: "level" },
          { title: "认证时间", dataKey: "certificationTime" },
          { title: "认证机关", dataKey: "source" }
        ],
        mock: [
          {
            title: "【国家发改委】国家企业技术中心B",
            level: "AA",
            source: "国家发改委",
            certificationTime: "2021-01-20"
          }
        ]
      }
    ]
  }
];
